package com.gyp.config;

import lombok.Data;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.Configuration;
import org.springframework.util.AntPathMatcher;
import org.springframework.util.PathMatcher;

import java.util.List;

/**
 * @author xyb
 * @Description 白名单地址配置
 * @since 19:14 2022/7/14
 */
@Configuration
@Data
@ConfigurationProperties(prefix = "ignore")
public class UrlIgnoreConfig {

    public static PathMatcher pathMatcher = new AntPathMatcher();

    private List<String> url;

    //权限验证
    public Boolean matchUrl(String path) {
        return url.stream().filter(var -> pathMatcher.match(var,path))
                .count() > 0 ? true : false;
    }

    public Boolean matchTokenUrl(List<String> data,String path) {
        return data.stream().filter(var -> pathMatcher.match(var,path))
                .count() > 0 ? true : false;
    }

}
